home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mnthlp95 / source / p.src < prev    next >
Text File  |  1992-08-04  |  41KB  |  1,127 lines

  1. screen(capsensitive("Pause"))
  2. NAME
  3.     Pause - suspend process until a signal is received
  4.  
  5. SYNOPSIS
  6.     void Pause(void);
  7.  
  8. DESCRIPTION
  9.     Pause causes the calling process to go to sleep until a sig-
  10.     nal that is not being ignored or masked is received. If a
  11.     signal handler has been established for that signal with the
  12.     \#Psignal\# system call, then the handler is invoked before
  13.     Pause returns; if the handler does a longjmp to a different
  14.     point in the program, if it exits the program, or if the
  15.     signal handler was set to SIG_DFL and the default action for
  16.     the signal is to terminate the process, then Pause will
  17.     never return.
  18.  
  19. SEE ALSO
  20.     \#Psigblock\#, \#Psignal\#, \#Psigpause\#, \#Psigsetmask\#
  21.  
  22. Last change: May 1, 1991\end
  23.  
  24. screen(capsensitive("Pdomain"))
  25. NAME
  26.     Pdomain - get or set process execution domain
  27.  
  28. SYNOPSIS
  29.     WORD Pdomain(WORD dom);
  30.  
  31. DESCRIPTION
  32.     Pdomain gets or sets the process execution domain. This is a
  33.     number which controls the behavior of a process. The default
  34.     domain is 0, which is the TOS compatibility domain and in
  35.     which all system calls behave exactly as they do under TOS.
  36.     Domain 1 is the MiNT domain; in this domain, the behavior of
  37.     the \#Fread\# and \#Fwrite\# system calls when applied to terminals
  38.     are controlled by the current terminal settings as esta-
  39.     blished by the \#Fcntl\# system call. Moreover, file names
  40.     returned from \#Fsfirst\# and \#Fsnext\# may be treated differently;
  41.     MiNT domain processes are expected to be able to deal with
  42.     file names that are not standard 8 character name + 3 char-
  43.     acter extension, all upper case, DOS file names.
  44.  
  45.     If dom is greater than or equal to 0, the process domain is
  46.     set to its value. Note that only domains 0 and 1 are
  47.     currently defined, and the result of using a different
  48.     (positive) number for dom is unpredictable. If dom is nega-
  49.     tive, no change is made to the process domain.
  50.  
  51. RETURNS
  52.     The process domain at the time of the Pdomain call (i.e.
  53.     before any change).
  54.  
  55. Last change: Oct. 1, 1991\end
  56.  
  57. screen(capsensitive("Pfork"))
  58. NAME
  59.     Pfork - create a copy of the current process
  60.  
  61. SYNOPSIS
  62.     WORD Pfork(void);
  63.  
  64. DESCRIPTION
  65.     Pfork creates a copy of the current process. The child (the
  66.     new process created) inherits a copy of the parent's address
  67.     space, not the parent's original memory, and so changes to
  68.     variables in the child do not affect the parent in any way.
  69.     The new process begins execution with an apparent return
  70.     from the Pfork call.
  71.  
  72. RETURNS
  73.     0 in the child
  74.  
  75.     The new process id (a positive number), in the parent.
  76.  
  77.     ENSMEM if there is not enough memory to create the new pro-
  78.     cess.
  79.  
  80. SEE ALSO
  81.     \#Pexec\#, \#Pvfork\#
  82.  
  83. BUGS
  84.     If the parent is in supervisor mode when this call is made,
  85.     the child will be started in user mode anyway; thus, it is
  86.     strongly recommended that this call be made only from user
  87.     mode.
  88.  
  89.     The current implementation of Pfork acts like Pvfork in that
  90.     the parent is suspended until the child either exits or
  91.     overlays itself with Pexec mode 200. Do not rely on this
  92.     behavior, as it will be changed in future versions of MiNT.
  93.  
  94. Last change: Oct. 1, 1991\end
  95.  
  96. screen(capsensitive("Pgetuid"),capsensitive("Pgetgid"),
  97.        capsensitive("Pgeteuid"),capsensitive("Pgetegid"))
  98. NAME
  99.     Pgetuid, Pgetgid - get the current user or group id
  100.  
  101. SYNOPSIS
  102.     WORD Pgetuid(void);
  103.     WORD Pgetgid(void);
  104.     WORD Pgeteuid(void);
  105.     WORD Pgetegid(void);
  106.  
  107. DESCRIPTION
  108.     Pgetuid returns the user id of the currently running pro-
  109.     cess. This is a number between 0 and 255 which determines
  110.     the access permissions of the process, and which may be used
  111.     in multi-user systems to distinguish different users of the
  112.     system.
  113.  
  114.     Similarly, Pgetgid returns the group id of the currently
  115.     running process; this will also be a number between 0 and
  116.     255.
  117.  
  118.     Pgeteuid and Pgetegid are similar to Pgetuid and Pgetgid
  119.     respectively, except that they return the effective user or
  120.     group id. This is normally the same as the real user or
  121.     group id, except that if a program is run which has the set
  122.     uid or set gid bit set, it will run with an effective
  123.     user or group id equal to the owner of the program file.
  124.     Access to files is based upon the effective user or group
  125.     id, so the set uid (and set gid) mechanism allows users (in
  126.     particular the super user) to grant permissions to other
  127.     users. This mechanism also exists in the Unix(tm) operating
  128.     system.
  129.     
  130. SEE ALSO
  131.     \#Psetuid\#
  132.  
  133. Last change: Aug. 1, 1992\end
  134.  
  135. screen(capsensitive("Pgetpgrp"))
  136. NAME
  137.     Pgetpgrp - get the current process group number
  138.  
  139. SYNOPSIS
  140.     WORD Pgetpgrp(void);
  141.  
  142. DESCRIPTION
  143.     Pgetpgrp returns the process group number of the currently
  144.     running process. Process groups are commonly used for job
  145.     control and other signalling purposes; processes that share
  146.     the same process group are assumed to be closely related,
  147.     and are usually stopped all together rather than 1 at a
  148.     time.
  149.  
  150. SEE ALSO
  151.     \#Pkill\#, \#Pgetpid\#, \#Psetpgrp\#
  152.  
  153. Last change: Oct. 1, 1991\end
  154.  
  155. screen(capsensitive("Pgetpid"))
  156. NAME
  157.     Pgetpid - get the current process id
  158.  
  159. SYNOPSIS
  160.     WORD Pgetpid(void);
  161.  
  162. DESCRIPTION
  163.     Pgetpid returns the process id of the currently running pro-
  164.     cess. This is a positive 16 bit integer which is unique
  165.     among all processes currently in the system. The call is
  166.     always successful.
  167.  
  168. SEE ALSO
  169.     \#Pgetpgrp\#, \#Pgetppid\#
  170.  
  171. Last change: Oct. 1, 1991\end
  172.  
  173. screen(capsensitive("Pgetppid"))
  174. NAME
  175.     Pgetppid - get the process id for the parent of the current
  176.     process
  177.  
  178. SYNOPSIS
  179.     WORD Pgetppid(void);
  180.  
  181. DESCRIPTION
  182.     Pgetppid returns the process id of the parent of the
  183.     currently running process. The process id is a positive 16
  184.     bit integer. The call is always successful.
  185.  
  186. SEE ALSO
  187.     \#Pgetpgrp\#, \#Pgetpid\#
  188.  
  189. NOTES
  190.     If the current process was started directly by the kernel,
  191.     then Pgetppid will return 0.
  192.  
  193. Last change: Oct. 1, 1991\end
  194.  
  195. screen(capsensitive("Pkill"))
  196. NAME
  197.     Pkill - send a signal to a process
  198.  
  199. SYNOPSIS
  200.     #include <signal.h>
  201.  
  202.     WORD Pkill(WORD pid, WORD sig);
  203.  
  204. DESCRIPTION
  205.     Pkill sends the signal described by sig to one or more
  206.     processes, as follows:
  207.  
  208.     If pid is a positive number, then the signal is sent to the
  209.     process with that process id.
  210.  
  211.     If pid is 0, the signal is sent to all members of the pro-
  212.     cess group of the calling process (i.e. all processes which
  213.     have the same process group number). This includes, of
  214.     course, the calling process itself.
  215.  
  216.     If pid is less than 0, the signal is sent to all processes
  217.     with process group number -pid.
  218.  
  219. RETURNS
  220.     0 if successful. Note that if the current process is a reci-
  221.     pient of the signal, the Pkill call may not return at all if
  222.     the process is killed.
  223.  
  224.     ERANGE if sig is not a valid signal.
  225.  
  226.     EFILNF if pid
  227.      > 0 and the indicated process has terminated or does not
  228.     exist, or if pid
  229.      < 0 and there are no processes in the corresponding process
  230.     group.
  231.  
  232.     EACCDN if pid > 0, the sending  process does not have an
  233.     effective user id of 0, and the recipient process has a dif-
  234.     ferent user id from the sending process.
  235.  
  236. SEE ALSO
  237.     \#Psetpgrp\#, \#Psignal\#
  238.  
  239. BUGS
  240.     The user id checks should also be performed when sending
  241.     signals to process groups. Do not rely on the lack of
  242.     checks, as this will be corrected at some point.
  243.  
  244. Last change: Oct. 1, 1991\end
  245.  
  246. screen(capsensitive("Pmsg"))
  247. NAME
  248.     Pmsg - send and receive brief messages
  249.  
  250. SYNOPSIS
  251.     struct msg { LONG msg1, msg2; WORD pid; };
  252.  
  253.     LONG Pmsg(WORD mode, LONG mboxid, struct msg *msgptr);
  254.  
  255. DESCRIPTION
  256.     Pmsg sends or receives a message to a specified message box.
  257.     What sort of operation is performed depends on the bits in
  258.     mode as follows:
  259.     Mode    Operation
  260.     0x0000  read
  261.     0x0001  write
  262.     0x0002  write, then read from mboxid 0xFFFFxxxx where
  263.             xxxx is the process id of the current process
  264.  
  265.     0x8000  OR with this bit to make the operation
  266.             non-blocking.
  267.  
  268.     The messages are five words long: two longs and a short, in
  269.     that order. The values of the first two longs are totally
  270.     up to the processes in question. The value of the short is
  271.     the PID of the sender. On return from writes, the short is
  272.     the PID of the process that read your message. On return
  273.     from reads, it's the PID of the writer.
  274.  
  275.     If the 0x8000 bit is set in the mode, and there is not a
  276.     reader/writer for the mboxid already, this call returns -1.
  277.     Otherwise, a read operation waits until a message is written
  278.     and a write operation waits for a reader to receive the mes-
  279.     sage.
  280.  
  281.     In mode 2, the writer is declaring that it wants to wait for
  282.     a reply to the message. What happens is that the reader
  283.     gets put on the ready queue, but the writer is atomically
  284.     turned into a reader on a mailbox whose mboxid is
  285.     (0xFFFF0000 | pid). The idea is that this process will sleep
  286.     until awoken at a later time by the process that read the
  287.     message. The process reading the original request is
  288.     guaranteed not to block when writing the reply.
  289.  
  290.  
  291. RETURNS
  292.     0 if successful
  293.  
  294.     -1 if bit 0x8000 is set and the Pmsg call would have to
  295.     block
  296.  
  297.     EINVFN if mode is invalid
  298.  
  299. USAGE
  300.     Used for short messages and as a way to do rendezvous and
  301.     interprocess communication with little overhead. For more
  302.     complicated messages or more general IPC, use FIFOs or
  303.     pseudo-terminals.
  304.  
  305. BUGS
  306.     There is no provision for a timeout.
  307.  
  308.     No checking is done for deadlocks. A deadlock could arise in
  309.     the following way: Say PID 33 writes in mode 2 to a message
  310.     box and it blocks. Then somebody writes to PD33 (i.e.  mes-
  311.     sage box (0xFFFF0000 | 33) ) and blocks because you're not
  312.     waiting for it. Then your write is satisfied, so you become
  313.     a reader on PD33. We should check to see if there are any
  314.     writers on PD33 and satisfy that rendezvous! But this could
  315.     go on forever, and it's easier to stop here. So you lose:
  316.     this situation is timing sensitive. It shouldn't come up
  317.     anyway.
  318.  
  319. AUTHOR
  320.     Allan K. Pratt
  321.  
  322. Last change: Oct. 1, 1991\end
  323.  
  324. screen(capsensitive("Pnice"))
  325. NAME
  326.     Pnice - change process priority for the current process
  327.  
  328. SYNOPSIS
  329.     WORD Pnice(WORD delta);
  330.  
  331. DESCRIPTION
  332.     Pnice changes the base process niceness for the current pro-
  333.     cess by the amount delta. Higher levels of niceness
  334.     correspond to decreased priority in scheduling, so  positive
  335.     values for delta cause the corresponding process to be
  336.     scheduled less often. Conversely, negative values for delta
  337.     cause the process priority to be increased.
  338.  
  339. RETURNS
  340.     The (adjusted) process priority, as a 16 bit signed integer.
  341.     0 is the default priority; values greater than 0 are for
  342.     higher priority processes (ones that are scheduled more
  343.     often), and values less than 0 are lower priority processes.
  344.  
  345. SEE ALSO
  346.     \#Prenice\#
  347.  
  348. BUGS
  349.     The scheduling algorithm is pretty weird, so it's hard to
  350.     predict exactly what effect process priorities have.
  351.  
  352. Last change: Oct. 1, 1991\end
  353.  
  354. screen(capsensitive("Prenice"))
  355. NAME
  356.     Prenice - change process priority
  357.  
  358. SYNOPSIS
  359.     LONG Prenice(WORD pid, WORD delta);
  360.  
  361. DESCRIPTION
  362.     Prenice changes the base process niceness for process pid by
  363.     the amount delta. Higher levels of niceness correspond to
  364.     decreased priority in scheduling, so positive values for
  365.     delta cause the corresponding process to be scheduled less
  366.     often. Conversely, negative values for delta cause the pro-
  367.     cess priority to be increased.
  368.  
  369. RETURNS
  370.     The current priority for the process, if successful. This is
  371.     a 16 bit signed quantity. The default priority is 0; higher
  372.     priority processes have larger priority values, lower prior-
  373.     ity ones have smaller values.
  374.  
  375.     EFILNF if the indicated process does not exist (note that
  376.     since this is a 32 bit negative number it can be dis-
  377.     tinguished from the WORD negative numbers returned for low
  378.     priority processes)
  379.  
  380.     EACCDN if the process has a different user id
  381.  
  382. SEE ALSO
  383.     \#Pnice\#
  384.  
  385. BUGS
  386.     The scheduling algorithm is pretty weird, so it's hard to
  387.     predict exactly what effect process priorities have.
  388.  
  389. Last change: Oct. 1, 1991\end
  390.  
  391. screen(capsensitive("Prusage"))
  392. NAME
  393.     Prusage - get resource usage information
  394.  
  395. SYNOPSIS
  396.     void Prusage(LONG *r);
  397.  
  398. DESCRIPTION
  399.     Prusage puts information on resources used by the process
  400.     into the memory pointed to by r, as follows:
  401.         r[0]: time spent by process in MiNT kernel
  402.         r[1]: time spent by process in its own code
  403.         r[2]: total kernel time spent by children of this process
  404.         r[3]: total user code time spent by children of this process
  405.         r[4]: memory allocated to this process (bytes)
  406.         r[5]-r[7]: reserved for future use
  407.     All times are in milliseconds.
  408.  
  409. SEE ALSO
  410.     \#Psetlimit\#
  411.  
  412. Last change: Oct. 1, 1991\end
  413.  
  414. screen(capsensitive("Psemaphore"))
  415. NAME
  416.     Psemaphore - create / use / destroy a sempahore
  417.  
  418. SYNOPSIS
  419.     LONG Psemaphore(WORD mode, LONG id, long timeout);
  420.  
  421. DESCRIPTION
  422.     Psemaphore is a call that implements uncounted semaphores. A
  423.     semaphore is used for mutual exclusion: only one process at
  424.     a time may "own" a given semaphore.
  425.  
  426.     For example, a semaphore may be used to protect access to
  427.     data structures which are in shared memory and which are
  428.     used by multiple threads in a process: before using the
  429.     memory a thread must gain ownership of the guarding sema-
  430.     phore, and when finished the thread must release the sema-
  431.     phore. The semaphore would be created during initialization
  432.     and destroyed during shutdown.
  433.  
  434.     Semaphores are identified by an id, which is an arbitrary
  435.     longword. This is the semaphore's "name." The id used to
  436.     create the semaphore is the "name" of that semaphore from
  437.     then on. When using semaphores, you should strive to use a
  438.     longword that is unique. Using four ASCII characters which
  439.     spell out something is common: 0x4b4f444f ("MODM") for
  440.     instance might be the id of a semaphore that controls access
  441.     to a modem. (Actually, this would be a poor choice, since
  442.     there can be more than one modem in a system and this sema-
  443.     phore ID isn't flexible enough to handle that. "MDM1" might
  444.     be better.)
  445.  
  446.     Semaphore id's beginning with 0x5f (the underscore charac-
  447.     ter) are reserved for operating system use.
  448.  
  449.     The timeout argument is only used in Mode 2. It is ignored
  450.     in other modes. A timeout of zero means "return immedi-
  451.     ately." A value of -1 means "forever" - that is, never time
  452.     out. Other values are a number of milliseconds to wait for
  453.     the semaphore before timing out.
  454.  
  455.     The mode argument is used to tell what operation the caller
  456.     desires:
  457.  
  458.     MODE ACTION
  459.  
  460.     0    Create and "get" a semaphore with the given ID.
  461.  
  462.     1    Destroy the indicated semaphore. The caller must own
  463.          the semaphore prior to making this call.
  464.  
  465.     2    Request ownership of the semaphore. Blocks until the
  466.          semaphore is free or until the timeout expires. See
  467.          below.
  468.  
  469.     3    Release the semaphore. The caller must own the sema-
  470.          phore prior to making this call.
  471.  
  472. RETURNS
  473.     CODE    MEANING
  474.  
  475.     0       Success.
  476.  
  477.     ERROR   A request for a semaphore which the caller 
  478.             already owns.
  479.  
  480.     ERANGE  The semaphore does not exist.
  481.  
  482.     EACCDN  Failure. The semaphore already exists (mode 0), 
  483.             you don't own it (modes 1 and 3), or the request
  484.             timed out (mode 2).
  485.  
  486.  
  487. NOTES
  488.     When you create a semaphore you also own it, so you must
  489.     release it before anybody else can get it. If you are
  490.     blocked waiting for a semaphore (mode 2 before the timeout
  491.     expires) and somebody destroys the semaphore, the call will
  492.     return ERANGE to you (because the requested semaphore does
  493.     not exist any more!).
  494.  
  495.     When a  process terminates, any semaphores it owns are
  496.     released.
  497.  
  498.     At most one process may own a semaphore. Ownership is not
  499.     inherited by children (fork()) or across exec().
  500.  
  501.     Once created, semaphores are never destroyed except upon
  502.     request. Thus if a program creates a semaphore and then
  503.     crashes the semaphore will never go away.
  504.  
  505.     Semaphores can be implemented using named pipes and file
  506.     locking. Technically, then, semaphores are redundant. The
  507.     facility is included as a kernel call because it was deemed
  508.     necessary to have this kind of exclusion available with lit-
  509.     tle persistent state or system-call overhead.
  510.  
  511. Last change: Jan. 6, 1992\end
  512.  
  513. screen(capsensitive("Psetuid"), capsensitive("Psetgid"))
  514. NAME
  515.     Psetuid, Psetgid - change a process' user or group id
  516.  
  517. SYNOPSIS
  518.     WORD Psetuid(WORD uid);
  519.     WORD Psetgid(WORD gid);
  520.  
  521. DESCRIPTION
  522.     Psetuid sets the user id of the current process to uid,
  523.     which must be a number between 0 and 255 inclusive. This
  524.     function call will fail if the user id is not already 0, so
  525.     once a process' user id is set it is fixed. Psetuid returns
  526.     uid, if the call is successful, and EACCDN if the process
  527.     does not have the authority to change its own user id (i.e.
  528.     if its effective user id is not 0 at the time of the call).
  529.  
  530.     Similarly, Psetgid sets the group id of the current process
  531.     to gid, which again must be between 0 and 255. The new group
  532.     id gid is returned if successful, and EACCDN is returned if
  533.     permission to change groups is denied.
  534.  
  535. SEE ALSO
  536.     \#Pgetuid\#, \#Pgetgid\#
  537.  
  538. BUGS
  539.     Security in MiNT is a joke; don't rely on these calls to
  540.     actually protect you from anything, it's more for informa-
  541.     tional purposes.
  542.  
  543. Last change: Oct. 1, 1991\end
  544.  
  545. screen(capsensitive("Psetlimit"))
  546. NAME
  547.     Psetlimit - get or set limits on use of system resources
  548.  
  549. SYNOPSIS
  550.     LONG Psetlimit(WORD lim, LONG value);
  551.  
  552. DESCRIPTION
  553.     Psetlimit gets or sets a resource limit for a process. Which
  554.     limit is affected is governed by the value of lim, as fol-
  555.     lows:
  556.         1: get/set maximum CPU time for process (in milliseconds)
  557.         2: get/set total maximum memory allowed for process
  558.         3: get/set limit on Malloc'd memory for process
  559.  
  560.     If value is negative, the limit is unchanged; if value is 0,
  561.     the corresponding resource is unlimited; otherwise, the
  562.     resource limit is set to value.
  563.  
  564.     Setting the "maximum memory" limit means the process is not
  565.     allowed to grow bigger than that size overall. Setting the
  566.     "maximum Malloc'ed" limit means that the process may allo-
  567.     cate no more than that much memory. The difference is that
  568.     the latter limit applies above and beyond the text+data+bss
  569.     size of the process.
  570.  
  571.     Using Psetlimit sets the corresponding limit for both the
  572.     process and any children it creates thereafter. Note that
  573.     the limits apply to each process individually; setting the
  574.     child CPU limit value to 1000 and then using \#Pfork\# to
  575.     create three children results in each of those children get-
  576.     ting a CPU limit value of one second. They do not have a
  577.     collective or sum total limit of one second.
  578.  
  579.     There is no restriction on increasing a limit. Any process
  580.     may set any of its limits or its childrens' limits to a
  581.     value greater than its current limit, or even to zero
  582.     (unlimited).
  583.  
  584.     Memory limits do not apply during execution of \#Pexec\#; that
  585.     is, if a process is limited to (say) 256KB of memory, it can
  586.     still exec a child which uses more.
  587.  
  588.     Memory limits are not retroactive: if a process owns 256KB
  589.     of memory and then calls Psetlimit to restrict itself to
  590.     128KB, it will not be terminated, but no \#Malloc\# calls will
  591.     succeed until its size drops below 128KB.
  592.  
  593.     CPU limits are retroactive, however: if a process has used
  594.     three CPU seconds and calls Psetlimit to restrict itself to
  595.     one second, it will immediately receive SIGXCPU and ter-
  596.     minate.
  597.  
  598. RETURNS
  599.     The old limit (0 if there was no limit).
  600.  
  601. BUGS
  602.     Since the limit applies to the process and its children, you
  603.     can't limit a child to, say, one millisecond of CPU time:
  604.     the parent must necessarily limit itself before creating the
  605.     child, and if it has used more than a millisecond itself, it
  606.     will die with SIGXCPU.  A new set of lim arguments is needed
  607.     that apply to the caller's future children without applying
  608.     to the caller.
  609.  
  610.     To alleviate this, the parent must create a child process
  611.     via Pvfork, and this process (which hasn't consumed any CPU
  612.     time yet) must call Psetlimit and then \#Pexec\# to create the
  613.     child that is meant to be limited.
  614.  
  615. SEE ALSO
  616.     \#Prusage\#
  617.  
  618. Last change: Oct. 1, 1991\end
  619.  
  620. screen(capsensitive("Psetpgrp"))
  621. NAME
  622.     Psetpgrp - set the process group number for a process
  623.  
  624. SYNOPSIS
  625.     LONG Pgetpgrp(WORD pid, WORD neewgrp);
  626.  
  627. DESCRIPTION
  628.     Psetpgrp sets the process group of the process with process
  629.     id pid to the number newgrp. The process must have the same
  630.     user id as the current process, or must be a child of that
  631.     process. If pid is 0, the process group of the current pro-
  632.     cess is set. If newgrp is 0, then the process group is set
  633.     equal to the process id of the process.
  634.  
  635. RETURNS
  636.     The new process group number, if successful.
  637.  
  638.     EFILNF if process pid does not exist.
  639.  
  640.     EACCDN if the process with id pid has a different user id
  641.     and is not a child of the calling process.
  642.  
  643. SEE ALSO
  644.     \#Pkill\#, \#Pgetpgrp\#, \#Pgetpid\#
  645.  
  646. Last change: Oct. 1, 1991\end
  647.  
  648. screen(capsensitive("Psigaction"))
  649. NAME  
  650.     Psigaction - change the way a signal is handled 
  651.  
  652. SYNOPSIS  
  653.     #include <signal.h>
  654.         
  655.     LONG Psigaction(WORD sig, struct sigaction *act, 
  656.                     struct sigaction *oact);
  657.  
  658. DESCRIPTION  
  659.     Psigaction changes the handling of the signal indicated by 
  660.     sig (which must be between 1 and 31; symbolic constants for 
  661.     symbols are defined in the file signal.h).  
  662.  
  663.     If act is non-zero, then it is assumed to point to a structure
  664.     describing the signal handling behavior. This structure has the 
  665.     following members:
  666.      
  667.     struct sigaction
  668.     {
  669.       LONG  sa_handler;
  670.       LONG  sa_mask;
  671.       WORD  sa_flags;
  672.     }
  673.     If sa_handler is SIG_DFL, then the default action for the
  674.     signal will occur when the signal is delivered to the process.  
  675.  
  676.     If sa_handler is SIG_IGN, then the signal will be ignored by
  677.     the process, and delivery of the signal will have no noticeable
  678.     effect (in particular, the signal will not interrupt the \#Pause\#
  679.     or \#Psigpause\# system calls). If the signal is pending at
  680.     the time of the \#Psignal\# call, it is discarded.  
  681.  
  682.     If sa_handler is some other value, it is assumed to be 
  683.     the address of a user function that will be called when the 
  684.     signal is delivered to the process. The user function is 
  685.     called with a single  LONG  argument  on the stack, which is 
  686.     the number of the signal being delivered (this is done so that
  687.     processes may use the same handler for a number of different 
  688.     signals).  While the signal is being handled, it is blocked  
  689.     from delivery; thus, signal handling is "reliable" (unlike 
  690.     Version 7 and early System V Unix implementations, in which 
  691.     delivery of a second signal while it was being handled could
  692.     kill the process). The set of signals specified in  sa_mask
  693.     are also blocked from delivery while the signal handler is 
  694.     executing. Note that, unlike in some versions of Unix, the 
  695.     signal handling is not reset to the default action before 
  696.     the handler is called; it remains set to the given signal
  697.     handler.  
  698.  
  699.     The signal handler must either return (via a normal 680x0 
  700.     rts instruction) or call the \#Psigreturn\# system call to
  701.     indicate when signal handling is complete; in both cases, 
  702.     the signal will be unblocked. \#Psigreturn\# also performs 
  703.     some internal clean-up of the kernel stack that is necessary 
  704.     if the signal handler is not planning to return (for example,
  705.     if the C longjmp() function is to be used to continue 
  706.     execution at another point in the program).  
  707.  
  708.     Signal handlers may make any GEMDOS, BIOS, or XBIOS system 
  709.     calls freely. GEM AES and VDI calls should not be made in a 
  710.     signal handler.  
  711.  
  712.     The sa_flags field specifies additional, signal-specific
  713.     signal handling behavior. If sig is SIGCHLD, and the 
  714.     SA_NOCLDSTOP bit is set in sa_flags, then the SIGCHLD
  715.     signal is sent to this process only when one of its children
  716.     terminates (and not when a child is suspended by a job control 
  717.     signal).  
  718.  
  719.     The oact argument to Psigaction, if non-zero, specifies a
  720.     structure that will be set to reflect the signal handling
  721.     for sig that was current at the time of the Psigaction
  722.     system call.  
  723.  
  724.     Note  that calling Psigaction to change behavior of a signal
  725.     has the side effect of unmasking that signal, so that
  726.     delivery is possible. This is done so that processes may, 
  727.     while handling a signal, reset the behavior and send 
  728.     themselves another instance of the signal, for example in 
  729.     order to suspend themselves while handling a job control signal.
  730.     Signal handling is preserved across \#Pfork\# and \#Pvfork\# calls.
  731.     Signals that are ignored by the parent are also ignored by
  732.     the child after a \#Pexec\# call; signals that were being caught
  733.     for handling in a function are reset in the child to the 
  734.     default behavior.  
  735.  
  736. RETURNS  
  737.     0 on success 
  738.  
  739.     ERANGE if sig is not a legal signal.  
  740.  
  741.     EACCDN if the signal may not be caught by the user 
  742.  
  743. SEE ALSO  
  744.     \#Pkill\#, \#Psigblock\#, \#Psignal\#, \#Psigreturn\#
  745.  
  746. BUGS  
  747.     Signal handling can be nested only a small (around 3) number
  748.     of times, i.e. if 4 signals are delivered to a process, and
  749.     the process has established handlers for all 4, and none of
  750.     the handlers has returned or called \#Psigreturn\#, then
  751.     there is a very good chance of a stack overflow killing the
  752.     process off. In practice, this is unlikely to happen.  
  753.  
  754. AUTHOR  
  755.     Alex Kiernan 
  756.  
  757. Last change: May 1, 1992\end
  758.  
  759. screen(capsensitive("Psigblock"), capsensitive("Psigsetmask"))
  760. NAME
  761.     Psigblock, Psigsetmask - block or unblock delivery  of  sig-
  762.     nals
  763.  
  764. SYNOPSIS
  765.     LONG Psigblock(LONG mask);
  766.     LONG Psigsetmask(LONG mask);
  767.  
  768. DESCRIPTION
  769.     Psigblock adds the set of signals defined by the variable
  770.     mask to the set of signals which are blocked from delivery.
  771.     Each bit of mask represents a signal; if bit n of mask is
  772.     set, then signal number n is blocked. Psigblock returns the
  773.     set of blocked signals as it was prior to the new signals
  774.     being added to it; the old set can thus be restored with the
  775.     Psigsetmask call.
  776.  
  777.     Psigsetmask replaces the set of blocked signals with the set
  778.     in mask; the bits of mask have the same meaning as they do
  779.     for Psigblock, except that bits that are set to 0 will cause
  780.     the corresponding signals to no longer be blocked. Psigset-
  781.     mask returns the old set of blocked signals.
  782.  
  783.     Note that certain signals (e.g. SIGKILL) cannot be blocked,
  784.     and the kernel will (silently) clear the corresponding bits
  785.     in mask before changing the blocked signal set.
  786.  
  787.     Blocked signals remain blocked across \#Pfork\# and \#Pvfork\#
  788.     calls. After a \#Pexec\# call, the child process will always
  789.     start with an empty set of blocked  signals, regardless of
  790.     which signals were blocked by the parent.
  791.  
  792. SEE ALSO
  793.     \#Pkill\#, \#Psignal\#, \#Psigpending\#
  794.  
  795. Last change: Oct. 1, 1991\end
  796.  
  797. screen(capsensitive("Psignal"))
  798. NAME
  799.     Psignal - change the way a signal is handled
  800.  
  801. SYNOPSIS
  802.     #include <signal.h>
  803.  
  804.     LONG Psignal(WORD sig, LONG handler);
  805.  
  806. DESCRIPTION
  807.     Psignal changes the handling of the signal indicated by sig
  808.     (which must be between 1 and 31; symbolic constants for sym-
  809.     bols are defined in the file signal.h). The new signal
  810.     handler applies to this process only.
  811.  
  812.     If handler is SIG_DFL, then the default action for the sig-
  813.     nal will occur when the signal is delivered to the process.
  814.  
  815.     If handler is SIG_IGN, then the signal will be ignored by
  816.     the process, and delivery of the signal will have no notice-
  817.     able effect (in particular, the signal  will not interrupt
  818.     the \#Pause\# system call). If the signal is pending at
  819.     the time of the Psignal call, it is discarded.
  820.  
  821.     If handler is some other value, it is assumed to be the
  822.     address of a user function that will be called when the sig-
  823.     nal is delivered to the process. The user function is called
  824.     with a single LONG argument on the stack, which is the
  825.     number of the signal being delivered (this is done so that
  826.     processes may use the same handler for a number of different
  827.     signals). While the signal is being handled, it is blocked
  828.     from delivery; thus, signal handling is "reliable" (unlike
  829.     Version 7 and early System V Unix implementations, in which
  830.     delivery of a second signal while it was being handled could
  831.     kill the process). Also note that, unlike some  versions of
  832.     Unix, the signal handling is not reset to the default
  833.     action before the handler is called; it remains set to the
  834.     given signal handler.
  835.  
  836.     The signal handler must either return (via a normal 680x0
  837.     rts instruction) or call the Psigreturn system call to indi-
  838.     cate when signal handling is complete; in both cases, the
  839.     signal will be unblocked. Psigreturn also performs some
  840.     internal clean-up of the kernel stack that is necessary if
  841.     the signal handler is not planning to return (for example,
  842.     if the C longjmp() function is to be used to continue execu-
  843.     tion at another point in the program).
  844.  
  845.     Signal handlers may make any GEMDOS, BIOS, or XBIOS system
  846.     calls freely. GEM AES and VDI calls should not be made in a
  847.     signal handler.
  848.  
  849.     Note that calling Psignal to change behavior of a signal has
  850.     the side effect of unmasking that signal, so that delivery
  851.     is possible. This is done so that processes may, while  han-
  852.     dling a signal, reset the behavior and send themselves
  853.     another instance of the signal, for example in order to
  854.     suspend themselves while handling a job control signal.
  855.     Signal handling is preserved across \#Pfork\# and \#Pvfork\# calls.
  856.     Signals that are ignored by the parent are also ignored by
  857.     the child after a \#Pexec\# call; signals that were being caught
  858.     for handling in a function are reset in the child to the
  859.     default behavior.
  860.  
  861. RETURNS
  862.     The old value of the signal handler on success; this will be
  863.     either SIG_DFL, SIG_IGN, or a function address.
  864.  
  865.     ERANGE if sig is not a legal signal.
  866.  
  867.     EACCDN if the signal may not be caught by the user
  868.  
  869. SEE ALSO
  870.     \#Pkill\#, \#Psigaction\#, \#Psigblock\#, \#Psigreturn\#
  871.  
  872. BUGS
  873.     Signal handling can be nested only a small (around 3) number
  874.     of times, i.e. if 4 signals are delivered to a process, and
  875.     the process has established handlers for all 4, and none of
  876.     the handlers has returned or called Psigreturn, the there
  877.     is a very good chance of a stack overflow killing the process
  878.     off. In practice, this is unlikely to happen.
  879.  
  880. Last change: May 1, 1992\end
  881.  
  882. screen(capsensitive("Psigpause"))
  883. NAME  
  884.     Psigpause - suspend process until a signal is received 
  885.  
  886. SYNOPSIS  
  887.     void Psigpause(LONG mask);
  888.  
  889. DESCRIPTION  
  890.     Psigpause sets a new signal mask and then causes the calling
  891.     process to go to sleep until a signal that is not being
  892.     ignored or masked is received. If a signal handler has been
  893.     established for that signal with the \#Psignal\# system call,
  894.     then the handler is invoked before Psigpause returns; if the
  895.     handler does a longjmp to a different point in the program,
  896.     if it exits the program, or if the signal handler was set to 
  897.     SIG_DFL and the default action for the signal is to terminate
  898.     the process, then Psigpause will never return.  
  899.  
  900.     If Psigpause does return, then the signal mask is restored 
  901.     to what it was prior to the Psigpause system call, i.e.
  902.     the new signal mask specified by mask is only temporary.  
  903.  
  904. SEE ALSO  
  905.     \#Pause\#, \#Psigblock\#, \#Psignal\#, \#Psigsetmask\# 
  906.  
  907. BUGS  
  908.     If a signal handler doesn't return (for example, because it
  909.     uses longjmp) then the signal mask is left set to mask.
  910.  
  911. AUTHOR  
  912.     Alex Kiernan
  913.     
  914. Last change: May 1, 1992\end
  915.  
  916. screen(capsensitive("Psigpending"))
  917. NAME
  918.     Psigpending - determine which signals have been sent but not
  919.     delivered
  920.  
  921. SYNOPSIS
  922.     LONG Psigpending(void);
  923.  
  924. DESCRIPTION
  925.     Psigpending returns a bit mask containing the signals that
  926.     have been sent to the calling process but not yet delivered
  927.     (probably because they have blocked, either directly via
  928.     Psigblock or Psigsetmask, or indirectly because of signal
  929.     handling.
  930.  
  931. RETURNS
  932.     Bit n of the returned value is set if (and only if) signal
  933.     number n is pending.
  934.  
  935. SEE ALSO
  936.     \#Psigblock\#, \#Psignal\#, \#Psigsetmask\#
  937.  
  938. Last change: Oct. 1, 1991\end
  939. screen(capsensitive("Psigreturn"))
  940. NAME
  941.     Psigreturn - exit from a signal handler
  942.  
  943. SYNOPSIS
  944.     void Psigreturn(void);
  945.  
  946. DESCRIPTION
  947.     Psigreturn is used to prepare to exit from a signal handler.
  948.     This is done automatically by the kernel when a signal
  949.     handler returns, so it is needed only before a program uses
  950.     the C longjmp function (or some similar facility) to do a
  951.     non-local jump. Psigreturn will fail (harmlessly) if no
  952.     signal is being processed at the time it is called.
  953.  
  954.     Note that the MiNT library longjmp function already contains
  955.     a call to Psigreturn, so if you're using that library you
  956.     don't need to worry about this.
  957.  
  958. SEE ALSO
  959.     \#Psignal\#
  960.  
  961. BUGS
  962.     Calling Psigreturn from a signal handler, and then actually
  963.     returning from that handler, is likely to produce extremely
  964.     unpleasant results.
  965.  
  966. Last change: Oct. 1, 1991\end
  967.  
  968. screen(capsensitive("Pumask"))
  969. NAME
  970.     Pumask - set file and directory creation mask
  971.  
  972. SYNOPSIS
  973.     WORD Pumask(WORD mode);
  974.  
  975. DESCRIPTION
  976.     Pumask changes the file and directory creation mask of the
  977.     current process to the unsigned 16 bit quantity specified in
  978.     mode. The old value of the creation mask is returned. Child
  979.     processes inherit the new value for the mask.
  980.  
  981.     When a new file is created with Fcreate or a new directory
  982.     created with \#Dcreate\# the initial access permissions (see
  983.     \#Fchmod\# for a description of these) for the newly created
  984.     file or directory are normally set so that all permissions
  985.     are granted (except that execute permission is not normally
  986.     granted for files). The creation mask set by Pumask deter-
  987.     mines which permissions are not to be granted by default.
  988.     Thus, files created after a Pumask(S_IWOTH|S_IWGRP|S_IXOTH)
  989.     call will be readable by anyone, but writable only by the
  990.     owner; moreover, directories created after this call would
  991.     be searchable by the owner and members of the same group,
  992.     but not by anyone else.
  993.  
  994. SEE ALSO
  995.     \#Dcreate\#, \#Fchmod\#, \#Fcreate\#
  996.  
  997. BUGS
  998.     Pumask doesn't affect explicit Fchmod calls, as some might
  999.     expect.
  1000.  
  1001. Last change: Oct. 1, 1991\end
  1002.  
  1003. screen(capsensitive("Pusrval"))
  1004. NAME
  1005.     Pusrval - get or set process specific information
  1006.  
  1007. SYNOPSIS
  1008.     LONG Pusrval(LONG val);
  1009.  
  1010. DESCRIPTION
  1011.     Pusrval may be used to set or retrieve the old process
  1012.     specific user value. This is a long word which is attached
  1013.     to the process, and is inherited by child processes. The use
  1014.     and meaning of the value is entirely up to applications; the
  1015.     kernel only records it.
  1016.  
  1017.     If val is -1 no change is made to the user value; otherwise
  1018.     it is set to val.
  1019.  
  1020. RETURNS
  1021.     The old process specific user value.
  1022.  
  1023. BUGS
  1024.     -1 cannot be used as a user value.
  1025.  
  1026. Last change: Oct. 1, 1991\end
  1027.  
  1028. screen(capsensitive("Pvfork"))
  1029. NAME
  1030.     Pvfork - create a copy of the current process
  1031.  
  1032. SYNOPSIS
  1033.     WORD Pvfork(void);
  1034.  
  1035. DESCRIPTION
  1036.     Pvfork creates a copy of the current process. Both the child
  1037.     (the new process created) and the parent (the process which
  1038.     first made the call) share the same address space, i.e. any
  1039.     changes that the child makes to variables will also be
  1040.     noticed by the parent. The new process begins execution
  1041.     with an apparent return from the Pvfork call.
  1042.  
  1043.     Because the two processes share the same address space,
  1044.     including the same stack, there could be many problems if
  1045.     they actually were running at the same time. Therefore, the
  1046.     parent process is suspended until the child process either
  1047.     exits or uses mode 200 of \#Pexec\# to overlay itself with a new
  1048.     program in a new address space.
  1049.  
  1050. RETURNS
  1051.     0 in the child
  1052.  
  1053.     The new process id (a positive number), in the parent.
  1054.  
  1055.     ENSMEM if there is not enough memory to create the new pro-
  1056.     cess.
  1057.  
  1058. SEE ALSO
  1059.     \#Pexec\#, \#Pfork\#
  1060.  
  1061. BUGS
  1062.     If the parent is in supervisor mode when this call is made,
  1063.     the child will be started in user mode anyway; thus, it is
  1064.     strongly recommended that this call be made only from user
  1065.     mode.
  1066.  
  1067. Last change: Oct. 1, 1991\end
  1068.  
  1069. screen(capsensitive("Pwait"), capsensitive("Pwait3"))
  1070. NAME
  1071.     Pwait, Pwait3 - get exit status of children
  1072.  
  1073. SYNOPSIS
  1074.     LONG Pwait(void);
  1075.     LONG Pwait3(WORD flag, LONG *rusage);
  1076.  
  1077. DESCRIPTION
  1078.     Pwait3 attempts to determine the exit code for any stopped
  1079.     children or children that have terminated. If bit 1 of flag
  1080.     is set, then children that are stopped due to job control
  1081.     are reported; otherwise only children that have actually
  1082.     terminated are reported. A stopped process will be reported
  1083.     at  most once (unless it is re-started and stopped again);
  1084.     similarly a terminated process will be reported only once.
  1085.  
  1086.     If the process does have children, but none are currently
  1087.     stopped or terminated and not yet waited for, then the
  1088.     behavior of Pwait3 is controlled by bit 0 of flag. If it is
  1089.     clear, the function will wait until some child is stopped or
  1090.     terminates; if it is set, the function will return immedi-
  1091.     ately.
  1092.  
  1093.     The rusage parameter, if non-zero, should point to two long
  1094.     words, into which information about the child's CPU time
  1095.     usage is placed, as follows:
  1096.     rusage[0]: milliseconds spent by child in user space
  1097.     rusage[1]: milliseconds spent by child in kernel space
  1098.  
  1099.     The Pwait() system call is equivalent to Pwait3(2,(LONG*)0),  
  1100.     and is provided both for convenience and for backward
  1101.     compatibility.
  1102.  
  1103. RETURNS
  1104.     If a child process is found, its process id is placed in the
  1105.     upper 16 bits of the 32 bit value returned, and its exit
  1106.     status (as passed to \#Pterm\# or \#Ptermres\#, as determined impli-
  1107.     citly by \#Pterm0\#, or as determined by the type of signal that
  1108.     stopped or killed the process) is placed in the lower 16
  1109.     bits. If the process was stopped or terminated by signal n,
  1110.     then its exit status will be ( n << 8 ) | x. where x is 127
  1111.     if the process was stopped and 0 if the process was ter-
  1112.     minated.
  1113.  
  1114.     0 if bit 0 of flag is set and the Pwait3 system call would
  1115.     have otherwise blocked waiting for a child to exit or stop.
  1116.  
  1117.     EFILNF if no unwaited for children exist.
  1118.  
  1119. SEE ALSO
  1120.     \#Pexec\#, \#Pterm\#, \#Pterm0\#, \#Ptermres\#
  1121.  
  1122. BUGS
  1123.     It is not possible to wait for a specific child process.
  1124.  
  1125. Last change: Oct. 1, 1991\end
  1126.  
  1127.